<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="报废单号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="报废日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="报废状态">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="设备商">
              <el-select v-model="dataForm.FSUPNAME" placeholder="请选择" >
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
            <el-form-item label="仓库">
              <el-select v-model="dataForm.FSTOCK" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="报废人员" prop="FUSER">
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>

        <el-col :span="16">
          <el-form-item label="报废说明" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核人员" prop="FCHECKUSE">
            <el-input v-model="dataForm.FCHECKUSE" disabled  />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核日期" prop="FCHECKDATE">
            <el-input v-model="dataForm.FCHECKDATE"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加设备</el-button> -->
            <el-button type="primary" @click="cancel">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">

<el-tab-pane label="设备列表" name="first">
  <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
      <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
      <el-table-column prop="FNUM" label="固定资产码"></el-table-column>
      <el-table-column prop="FCATNO" label="设备序列号" ></el-table-column>
      <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
      <el-table-column prop="FBRAND" label="设备品牌" ></el-table-column>
      <el-table-column prop="FSPEC" label="设备型号" ></el-table-column>
      <el-table-column prop="FUNIT" label="设备单位" width="85"></el-table-column>
      <el-table-column prop="FQTY"  label="报废数量" width="85" align="right"></el-table-column>
      <el-table-column prop="FMEMO" label="报废说明" ></el-table-column>
    </el-table>
    
    <div class="addbox">
       <el-link icon="el-icon-plus" type="primary" @click="insert">添加一行</el-link>
    </div>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
</el-tab-pane>

<el-tab-pane label="设备序列号" name="third">
  <el-table :data="list2" border stripe>
    <el-table-column label="操作" width="80">
      <template slot-scope="scope">
        <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
          type="text">删除</el-button>
      </template>
    </el-table-column>
    <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
    <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
    <el-table-column prop="FCATNO" label="设备编号"></el-table-column>
    <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
    <el-table-column prop="FSPEC" label="型号" ></el-table-column>
    <el-table-column prop="FNUM" label="序列号" ></el-table-column>
    <el-table-column prop="FMEMO" label="报废说明" ></el-table-column>
 </el-table>
  <div class="addbox">
       <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
  </div>
</el-tab-pane>


</el-tabs>
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FBILLNO :"Q241130001",
          FUSERNUMBER:"241001",
          FUSER: "韩信",
          FUSERTYPE:"本院人员",
          FBILLCREDATE: "2024-11-25",
          FMEMO: "学生损坏",
          FBEGDATE: "2024-12-01",
          FENDDATE: "2025-11-30",
          FSTOCK:"化学系仓库",
          FSUPPLIER:"生物系仓库",
          FCHECKUSE: "汉武帝",
          FBILLSTATE: "未提交",
          FCHECKDATE: "",
          FNOTE: ""
        },
        rules: {
          FUSER: [
            { required: true, message: '请输入领出人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入领出说明', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FTYPE": "手环",
                  "FNUM":"2412080000008",
                  "FCATNO":"XL-89-23981",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"Gv100",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":1,
                  "FTYPE": "摄像头",
                  "FNUM":"2411300000008",
                  "FCATNO":"TP-77-23981",
                  "FCATNAME": "智能迷你摄像头",
                  "FBRAND":"迷你",
                  "FSPEC":"TP090",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '申请中'
        }, {
          value: '2',
          label: '已退回'
        }, {
          value: '3',
          label: '已驳回'
        }],

        //仓库
        options2: [{
          value: '1',
          label: '化学系仓库'
        }, {
          value: '2',
          label: '生物系仓库'
        }],

        //供应商
        options3: [{
          value: '1',
          label: '奉1教楼101'
        }, {
          value: '2',
          label: '奉1教楼102'
        }, {
          value: '3',
          label: '奉综合楼201'
        }, {
          value: '4',
          label: '奉综合楼202'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>